﻿/*
 ***************************************************************************
 * Microsoft Visual C# .NET
 * 名称：       App_Search_HealthArchivesMdcViewForm
 * 类型：       控制层
 * 功能说明：   健康档案查询-用药详细显示页面
 * 作者：       章 昕
 * 创建日期：   2007/09/27
 * 修改日期     修改者      修改内容
 * 
 * 
 * ---
 ***************************************************************************
*/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shpm.App.Input.Bean;
using log4net;
using Shpm.System;
using Shpm.App.Commons.Db.Beans.Master;
using Shpm.App.Commons.Utils;
using Shpm.App.Search.Dao;
using Shpm.System.Validator;
using Shpm.System.Web.Control;
using Shpm.App.Input.Dao;

public partial class App_Search_HealthArchivesMdcViewForm : System.Web.UI.Page
{
    // log
    protected static ILog log = LogManager.GetLogger(typeof(App_Search_HealthArchivesMdcViewForm));

    // page load
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {        
            // view mode
            ViewState["MEMBER_MEDICINE_ID"] = Convert.ToString(Request.QueryString["MEMBER_MEDICINE_ID"]);
        }
    }

    // before render
    void Page_PreRender(object sender, EventArgs e)
    {
        HealthMedicineDao dao = new HealthMedicineDao();
        HealthMedicineDetailBean beanDetail = new HealthMedicineDetailBean();
        beanDetail.MemberMedicineId = Convert.ToInt32(ViewState["MEMBER_MEDICINE_ID"]);
        IList lstDetail = dao.ListDetail(beanDetail);

        viewSrhRst.DataSource = lstDetail;
        viewSrhRst.DataBind();

        // 取得当前登录的医生id信息
        SysUserManager manager = new SysUserManager(Context);
        SysUserBean sysUserBean = manager.getSysUserBean();
        MstSysUserBean mstSysUserBean =
            sysUserBean == null ? null : sysUserBean.getMstSysUserBean();
        MstEmployeeBean mstEmpBean =
            sysUserBean == null ? null : sysUserBean.getEmployeeBean();
        string loginId = mstSysUserBean == null ? "" : mstSysUserBean.SysUserId;
        string emplyId = mstSysUserBean == null ? "" : mstSysUserBean.EmployeeId;
        string emplyRole = mstEmpBean == null ? "" : mstEmpBean.Role;
        string emplyJob = mstEmpBean == null ? "" : mstEmpBean.EmployeeJob;
        string emplyLev = mstEmpBean == null ? "" : mstEmpBean.EmployeeLevel;    

        HealthMedicineBean beanBaseInf = new HealthMedicineBean();
        beanBaseInf.MemberMedicineId = Convert.ToInt32(ViewState["MEMBER_MEDICINE_ID"]);
        beanBaseInf.DoctorId = emplyId;
        beanBaseInf.EmployeeLevel = emplyLev;        
        IList lstBaseInf = dao.ListMain2(beanBaseInf);
        if (lstBaseInf != null && lstBaseInf.Count > 0)
        {
            beanBaseInf = (HealthMedicineBean)lstBaseInf[0];
            lblMemSex.Text = beanBaseInf.MemberSex;
            lblMemId.Text = beanBaseInf.MemberNo;
            lblMemName.Text = beanBaseInf.MemberName;
            lblMemTel.Text = beanBaseInf.MemberTel;
            lblRoomNo.Text = beanBaseInf.ApartmentNo;
            lblDocId.Text = beanBaseInf.DoctorId;
            lblMedicineType.Text = beanBaseInf.MedicineType;
            lblStopMedicine.Text = "正常";
            if (beanBaseInf.CancelFlg != null && beanBaseInf.CancelFlg.Value)
                lblStopMedicine.Text = "停药";
            if (beanBaseInf.BeginDate != null)
                lblStart.Text = DateUtils.convertToString(beanBaseInf.BeginDate.Value);
            if (beanBaseInf.EndDate != null)
                lblEnd.Text = DateUtils.convertToString(beanBaseInf.EndDate.Value);
        }
    }
}
